.class public final Lcom/burstly/lib/constants/BurstlyProperties;
.super Ljava/lang/Object;
.source "BurstlyProperties.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/burstly/lib/constants/BurstlyProperties$PropertyKey;
    }
.end annotation


# static fields
.field public static final TAG:Ljava/lang/String;

.field private static volatile sIsLoaded:Z

.field private static sProperties:Ljava/util/Properties;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 36
    const-class v0, Lcom/burstly/lib/constants/BurstlyProperties;

    invoke-virtual {v0}, Ljava/lang/Class;->getName()Ljava/lang/String;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/constants/BurstlyProperties;->TAG:Ljava/lang/String;

    .line 41
    new-instance v0, Ljava/util/Properties;

    invoke-direct {v0}, Ljava/util/Properties;-><init>()V

    sput-object v0, Lcom/burstly/lib/constants/BurstlyProperties;->sProperties:Ljava/util/Properties;

    return-void
.end method

.method private constructor <init>()V
    .locals 0

    .prologue
    .line 51
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 53
    return-void
.end method

.method private static close(Ljava/io/InputStream;)V
    .locals 1
    .parameter "in"

    .prologue
    .line 96
    if-eqz p0, :cond_0

    .line 98
    :try_start_0
    invoke-virtual {p0}, Ljava/io/InputStream;->close()V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    .line 104
    :cond_0
    :goto_0
    return-void

    .line 100
    :catch_0
    move-exception v0

    goto :goto_0
.end method

.method public static getString(Ljava/lang/String;)Ljava/lang/String;
    .locals 3
    .parameter "propKey"

    .prologue
    .line 114
    invoke-static {}, Lcom/burstly/lib/BurstlySdk;->wasInit()Z

    move-result v0

    if-eqz v0, :cond_1

    .line 115
    sget-boolean v0, Lcom/burstly/lib/constants/BurstlyProperties;->sIsLoaded:Z

    if-eqz v0, :cond_0

    .line 116
    sget-object v0, Lcom/burstly/lib/constants/BurstlyProperties;->sProperties:Ljava/util/Properties;

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "Can not find property with key :"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, p0, v1}, Ljava/util/Properties;->getProperty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    .line 118
    :goto_0
    return-object v0

    :cond_0
    const-string v0, "Property file is not initialized!"

    goto :goto_0

    .line 120
    :cond_1
    new-instance v0, Lcom/burstly/lib/exception/BurstlySdkNotInitializedException;

    invoke-direct {v0}, Lcom/burstly/lib/exception/BurstlySdkNotInitializedException;-><init>()V

    throw v0
.end method

.method public static initProperties(Landroid/content/Context;)V
    .locals 1
    .parameter "context"

    .prologue
    .line 61
    sget-boolean v0, Lcom/burstly/lib/constants/BurstlyProperties;->sIsLoaded:Z

    if-nez v0, :cond_0

    .line 62
    const-string v0, "burstly.properties"

    invoke-static {p0, v0}, Lcom/burstly/lib/constants/BurstlyProperties;->loadPropertiesFromFile(Landroid/content/Context;Ljava/lang/String;)V

    .line 63
    const-string v0, "version.properties"

    invoke-static {p0, v0}, Lcom/burstly/lib/constants/BurstlyProperties;->loadPropertiesFromFile(Landroid/content/Context;Ljava/lang/String;)V

    .line 64
    const/4 v0, 0x1

    sput-boolean v0, Lcom/burstly/lib/constants/BurstlyProperties;->sIsLoaded:Z

    .line 66
    :cond_0
    return-void
.end method

.method private static loadPropertiesFromFile(Landroid/content/Context;Ljava/lang/String;)V
    .locals 6
    .parameter "context"
    .parameter "fileName"

    .prologue
    .line 76
    invoke-virtual {p0}, Landroid/content/Context;->getAssets()Landroid/content/res/AssetManager;

    move-result-object v0

    .line 77
    .local v0, assetsManager:Landroid/content/res/AssetManager;
    const/4 v2, 0x0

    .line 79
    .local v2, in:Ljava/io/InputStream;
    :try_start_0
    invoke-virtual {v0, p1}, Landroid/content/res/AssetManager;->open(Ljava/lang/String;)Ljava/io/InputStream;

    move-result-object v2

    .line 80
    sget-object v3, Lcom/burstly/lib/constants/BurstlyProperties;->sProperties:Ljava/util/Properties;

    invoke-virtual {v3, v2}, Ljava/util/Properties;->load(Ljava/io/InputStream;)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 86
    invoke-static {v2}, Lcom/burstly/lib/constants/BurstlyProperties;->close(Ljava/io/InputStream;)V

    .line 88
    :goto_0
    return-void

    .line 82
    :catch_0
    move-exception v1

    .line 83
    .local v1, e:Ljava/lang/Exception;
    :try_start_1
    sget-object v3, Lcom/burstly/lib/constants/BurstlyProperties;->TAG:Ljava/lang/String;

    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    const-string v5, "FATAL ERROR! Application could not find properties file: "

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-static {v3, v4}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 86
    invoke-static {v2}, Lcom/burstly/lib/constants/BurstlyProperties;->close(Ljava/io/InputStream;)V

    goto :goto_0

    .end local v1           #e:Ljava/lang/Exception;
    :catchall_0
    move-exception v3

    invoke-static {v2}, Lcom/burstly/lib/constants/BurstlyProperties;->close(Ljava/io/InputStream;)V

    throw v3
.end method
